<?php
if (!defined("_INDEX")) { header("Location: /"); die; }

require_once ADMIN.DS."/head.php";
?>
<h1>Список брокеров</h1>
<br />
<a href="/admin/brokers" <?php
if ($route->GET("type") != "city"){
	echo "style='font-weight:bold'";
}
?>>Все брокеры</a> | <a href="/admin/brokers?type=city" <?php
if ($route->GET("type") == "city"){
	echo "style='font-weight:bold'";
}
?>>Брокеры в <?php echo $current_admin_city['name_pred']; ?></a><br /><br />
<input type="text" placeholder="Поиск..." id="search" />
<br /><br />
<div class='floating'><a href='/admin/brokers/add'>Добавить брокера</a></div>
<table cellpadding='0' cellspacing='0' class='list' id="table">
	<tr class='table_header'>
		<td width='50px'>ID</td>
		<td width='300px'>Название</td>
		<td width='200px' class='actions'>Действия</td>
	</tr><?php
		if ($route->GET("type") == "city"){
			$query = "select * from `brokers` where `city_id` = '".$current_admin_city['city_id']."' order by `name`";
		} else {
			$query = "select * from `brokers` order by `name`";
		}
		$brokers = $db->getTable($query);
		foreach ($brokers as $broker)
		{
			echo "<tr class='tr'><td>$broker[broker_id]</td>";
			echo "<td class='find'>$broker[name]</td>";
			echo "<td class='actions'><a href='/admin/brokers/edit/$broker[broker_id]' class='edit'>Редактировать</a> | <a href='/admin/brokers/delete/$broker[broker_id]' class='delete'>Удалить</a></td></tr>";
		}
?></table>

<?php require_once ADMIN.DS."/footer.php"; ?>